<?php
//connect to your database
mysql_connect("localhost:3306","root","expedia") or die("Unable to connect to MySQL ".mysql_error());
@mysql_select_db("eandb") or die( "Unable to select database ".mysql_error());
$term = trim(strip_tags($_GET['term']));//retrieve the search term that autocomplete sends

$qstring = "SELECT DISTINCT City AS value FROM activepropertylist WHERE City LIKE '%".$term."%' LIMIT 8";
//$qstring = "SELECT Name AS value,EANHotelID AS id FROM activepropertylist WHERE Name LIKE '%".$term."%' LIMIT 8";
//$qstring = "SELECT Name AS value,EANHotelID AS id FROM activepropertylist LIMIT 5";
$result = mysql_query($qstring) or die(mysql_error()) ;//query the database for entries containing the term

while ($row = mysql_fetch_array($result,MYSQL_ASSOC))//loop through the retrieved values
{
	 $row['value']=htmlentities(stripslashes($row['value']));
	 //$row['id']=(int)$row['id'];
	 $row_set[] = $row;//build an array
}
echo json_encode($row_set);//format the array into json data
mysql_close();
?>
